package com.liu.io.file.pdf;

import com.lowagie.text.Document;
import com.lowagie.text.pdf.BaseFont;
import com.lowagie.text.pdf.PdfContentByte;
import com.lowagie.text.pdf.PdfWriter;

import java.io.FileOutputStream;
import java.io.IOException;

/**
 * @author 刘忠奇 创建时间 2012-11-13下午4:11:45
 * 
 */
public class MyPdfWriter {
	public static void main(String[] args) {
		MyPdfWriter pdf = new MyPdfWriter();
		try {
			pdf.pdfWriter();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	public void pdfWriter() throws IOException {
		Document doc = new Document(com.lowagie.text.PageSize.A4);
		try {
			PdfWriter writer = PdfWriter.getInstance(doc,
					new FileOutputStream("C:/Users/12961/Desktop/Velocity标签技术.pdf"));
			doc.open();
			PdfContentByte cb = writer.getDirectContent();
			cb.beginText();
			BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
			cb.setFontAndSize(bf, 10);
			cb.setTextMatrix(10, 800);
			cb.showText("123123123");
			cb.endText();
//			System.out.println(doc.getPageSize().getWidth()+":"+doc.getPageSize().getHeight());
			doc.close();
		} catch (com.lowagie.text.DocumentException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
